package club.easin.product.dao;

import java.util.List;
import java.util.Map;

import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import club.easin.product.bean.Fault;

@Repository
public interface FaultRepository extends Neo4jRepository<Fault, Long>{
	
	/**根据故障现象查询故障名称和检查方法*/
	@Query("match(n:Phenomenon{phenomenon:{phenomenon}})<-[r:ACCOMPANY]-(m:Fault) "
			+ "with n,m match(m:Fault)<-[r1:HAS]-(k:Range{name:{rangeName}}) with m,n,k match(m:Fault)-"
			+ "[r:NEED_CHECK]->(c) return m.name as name,c.type as type")
	public List<Map<String,Object>> getFalultByPhenomenon(@Param("phenomenon")String phenomenon,@Param("rangeName")String rangeName);
	
	/**根据故障现象查找故障引起原因和解决办法*/
	@Query("match(n:Type{type:{type}})<-[r:BELONG_TO]-(m:Reason) return m.reason as reason,m.way as way")
	public List<Map<String,Object>> getReasonAndWay(@Param("type")String type);
	


}
